import Base from '@/controller/public/MiniBaseController';

export default class InitDataSource extends Base {
  async initRole() {
    const roles = [
      { name: 'patient', description: '患者' },
      { name: 'kinsfolk', description: '亲属' },
    ];
    for (const role of roles) {
      let existing_role = await this.roleRepository.findOne({
        where: { name: role.name },
      });
      if (!existing_role) {
        console.log('添加初始角色' + role.name);
        await this.roleRepository.save(role);
      }
    }
  }
  async initSymptom() {
    const symptoms = [
      { name: '高血压', id: 1 },
      { name: '冠心病', id: 2 },
      { name: '糖尿病', id: 3 },
      { name: '心肌病', id: 4 },
      { name: '心脏瓣膜病', id: 5 },
      { name: '心律失常', id: 6 },
      { name: '脑卒中', id: 7 },
    ];
    for (const symptom of symptoms) {
      let existing_symptom = await this.symptomRepository.findOne({
        where: { name: symptom.name },
      });
      if (!existing_symptom) {
        console.log('添加初始病例' + symptom.name);
        await this.symptomRepository.save(symptom);
      }
    }
  }
}
